<template>
	<web-view @load="bindloads" :src="url"></web-view>
</template>

<script setup>
	import { ref } from 'vue';
	import { port, goIndex, loading, closeLoading } from '/service/port';
	import { onLoad, onShow } from '@dcloudio/uni-app';

	const url = ref('');
	const open = ref('');
	onLoad((e) => {
		if (e.open) {
			url.value = decodeURIComponent(e.url);
			open.value = e.open;
		} else {
			url.value = e.url + '?token=' + e.token;
		}

		if (!e.open) {
			loading();
		}
	});

	function bindloads() {
		if (!open.value) {
			setTimeout(() => {
				closeLoading();
				goIndex('/pages/index');
			}, 300);
		}
	}
</script>
